<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Yy</title>
</head>

<body>
    <h1></h1>
    <script>
        // 1.在网页中显示当前时间。
        let h1 = document.querySelector("h1");
        setInterval(() => {
            let timeNow = new Date();
            let hours = timeNow.getHours();
            let minutes = timeNow.getMinutes();
            let seconds = timeNow.getSeconds();
            let time = `${hours}:${minutes}:${seconds}`
            h1.innerHTML = time;
        }, 500)
    </script>
</body>

</html>